package com.qhit.dao.impl;

import com.qhit.dao.BaseDao;
import com.qhit.entity.Student;

import java.lang.reflect.Field;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @author 村头老杨头
 * @version 1.0
 * @date 2021/9/27 11:28
 */
public class StudentDaoImpl extends BaseDao<Student> {
    public Student getStudentById(String sno) throws Exception {
        //SQL预处理
        String sql = "select * from student where sno=?";
        List<Student> studentList = executeQuery(Student.class, sql, sno);
        //返回
        if(studentList.size()>0){
            return studentList.get(0);
        }
        return  null;
    }
    public List<Student> getStudentList() throws Exception {
        String sql = "select * from student";
        List<Student> studentList = executeQuery(Student.class, sql);
        return studentList;
    }
    public int deleteStudent(String sno){
        String sql = "delete from student where sno=?";
        return executeUpdate(sql, sno);
    }
}
